<?php
namespace app\common\model;
use think\Model;
use think\model\concern\SoftDelete;

class User extends Model
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $defaultSoftDelete = 0;
    protected $autoWriteTimestamp = true;
    protected $disuse = [ 'plain_code', 'pay_code' ];

    protected function base($query)
    {

    }
    //等级
    protected function rank()
    {
        return self::belongsTo(Rank::class, 'rank_id')->bind(['rank_name'=>'name']);
    }
    protected function wechat()
    {
        return self::belongsTo(Wechat::class, 'id','user_id')->bind(['nickname']);
    }
    //会员列表
    public static function getUserList($where = 0)
    {
        return self::with(['rank','wechat'])->whereOr($where)->withoutField('password,plain_code,pay_pwd,pay_code')->order('id desc')->paginate();
    }

    //性别
    protected function getGenderAttr($value)
    {
        $Gender = ['未知','男','女'];
        return $Gender[$value];
    }
    //转账状态
    // protected function getIsFrozenAttr($value)
    // {
    //     $is_frozen = ['禁转','正常'];
    //     return $is_frozen[$value];
    // }
    // //is_active
    // protected function getIsActiveAttr($value)
    // {
    //     $is_active = ['未激活','已激活'];
    //     return $is_active[$value];
    // }
    // //status
    // protected function getStatusAttr($value)
    // {
    //     $status = ['禁用','正常'];
    //     return $status[$value];
    // }

}